package pattern.protectproxy;

import java.lang.reflect.Proxy;

public class Init
{
	public static void main(String[] args)
	{
		Init init = new Init();
		PersonBean bean = new PersonBeanImpl();
		bean.setName("hahahahahah");
		bean.setRating(5);
		PersonBean proxy = init.getOwnerProxy(bean);
		proxy.getName();
	}
	
	public PersonBean getOwnerProxy(PersonBean personBean)
	{
		return (PersonBean) Proxy.newProxyInstance(personBean.getClass().getClassLoader(), personBean.getClass()
				.getInterfaces(), new OwnerInvocationHandler(personBean));
	}
}
